import request from '/@/utils/request';

/**
 * @method getAllUserByPage 获取后端动态路由菜单(admin)
 * @method getUserById 获取后端动态路由菜单(test)
 * @method getUserByUsername
 * @method updateUser
 * @method deleteUserById
 * @method enableUserById
 */
export default function () {
	// 分页获取用户所有信息
	const getAllUserByPage = (params: object) => {
		return request({
			url: '/user/getalluserbypage',
			method: 'post',
			data: params,
		});
	};

	// 通过id获取用户信息
	const getUserById = (params:object) => {
		return request({
			url: '/user/getuserbyid',
			method: 'get',
			data: params,
		});	
	};
	
	// 通过userName获取用户信息
	const getUserByUsername = (params:object) => {
			return request({
				url: '/user/getuserbyusername',
				method: 'get',
				data: params,
			});
		};
	
	// 更新用户信息
	const updateUser = (params:object) => {
			return request({
				url: '/user/updateuser',
				method: 'post',
				data: params,
			});
		};
	
	// 删除用户
	const deleteUserById = (params:object) => {
			return request({
				url: '/user/deleteuserbyid',
				method: 'get',
				data: params,
			});
		};
	
	// 重启用户
	const enableUserById = (params:object) => {
			return request({
				url: '/user/enableuserbyid',
				method: 'get',
				data: params,
			});
		};

	return {
		getAllUserByPage,
		getUserById,
		getUserByUsername,
		updateUser,
		deleteUserById,
		enableUserById

	};


}
